package com.lzw.breadknife.sample.mvvm.base;

import android.app.Activity;
import android.content.Context;

import com.lzw.breadknife.Unbinder;

/**
 * author  : AWeiLoveAndroid
 * e-mail  : lzw460433675@163.com
 * github  : https://gitee.com/AWeiLoveAndroid/BreadKnife
 * project : BreadKnife
 */
public abstract class BaseViewModel<V extends IBaseView, M extends IBaseModel, B extends Unbinder> extends AbsViewModel<V> implements IBaseViewModel {

    public V view;
    public M model;
    public B unBinder;

    public BaseViewModel(V view, B unBinder) {
        this.attachView(view);
        this.attachUnbinder(unBinder);
        this.view = getView();
        this.unBinder = (B) getUnbinder();
        model = createModel();
    }

    protected abstract M createModel();

    @Override
    public Context applicationContext() {
        return view.applicationContext();
    }

    @Override
    public Activity context() {
        return view.context();
    }
}
